import { Component, OnInit } from '@angular/core';
// import { FormsModule } from '@angular/forms';
import { DeleteService } from './delete.service';
import { DataService } from '../../../../../services/data.service';

@Component({
  selector: 'app-delete',
  templateUrl: './delete.component.html',
  styleUrls: ['./delete.component.scss'],
  providers: [DeleteService]
})
export class DeleteComponent implements OnInit {
  //#delete modal创建时传值
  public item: any;
  // //请求体
  // public nFgId: any;
  // public sType: any;
  // //页面展示
  // public sFgName: any;
  // public sFgDesc: any;
  // public sFgMemberValid: any;

  constructor(
    public deleteService: DeleteService,
    public dataService: DataService
  ) { }

  ngOnInit() {
    console.log(this.item);
  }
  //删除群组
  delProduct() {
    let that = this;
    window["swal"](
      {
        type: "warning",
        showCancelButton: true,
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        closeOnConfirm: false,
        showLoaderOnConfirm: true,
        title: "提示",
        text: "<div style='max-height: 200px;overflow-y: auto;'>" + "请确认是否删除：" + "</div>",
        html: true
      },
      function (isConfirm) {
        if (isConfirm) {
          let putBody: any = {
            nFgId: that.item.nFgId,
            sType: that.item.sType,
          };
          if (that.item.sStatus == "正常") {
            that.deleteService.delProduct(putBody).subscribe(data => {
              if (data) {
                that.dataService.rcmiEditEmitter.emit('delete');
                window["swal"]("成功", '请等待删除审核', "success");
              }
            });
          } else {
            that.deleteService.delAddProduct(putBody).subscribe(data => {
              if (data) {
                that.dataService.rcmiEditEmitter.emit('delete');
                window["swal"]("成功", '添加待审已删除', "success");
              }
            });
          }
        }
      }
    );
  }
}
